/*
 * @Description: 路由配置文件
 * @Version: 2.0
 * @Autor: lhl
 * @Date: 2020-11-21 09:08:00
 * @LastEditors: lhl
 * @LastEditTime: 2021-08-21 20:44:17
 */
import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

// 路由懒加载 webpackChunkName如果一样就打成一个js文件不一样就打成多个文件
const routes = [
  {
    path: "/",
    redirect: "/index",
  },
  {
    path: "/index",
    name: "index",
    component: () =>
      import(/* webpackChunkName: "vantTest" */ "@/components/layout"),
    redirect: "/home",
    children: [
      {
        path: "/home",
        name: "home",
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () =>
          import(/* webpackChunkName: "vantTest" */ "../views/home"),
      },
      {
        path: "/product",
        name: "product",
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () =>
          import(/* webpackChunkName: "vantTest" */ "../views/product"),
      },
      {
        path: "/car",
        name: "car",
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () =>
          import(/* webpackChunkName: "vantTest" */ "../views/car"),
      },
      {
        path: "/my",
        name: "my",
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () =>
          import(/* webpackChunkName: "vantTest" */ "../views/my"),
      },
    ],
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
